from marshmallow import Schema
from flask_restplus import Namespace, fields


class RuelCostSchemas(object):
    def __init__(self, namespace):
        self.namespace = namespace

    def RuelImageCreateSchemas(self):
        return self.namespace.model(
            "ruel_cost_images",
            {"id": fields.Integer(), "ruel_cost": fields.Integer(), "file": fields.String()},
        )

    def RuelImageIdSchemas(self):
        return self.namespace.model("ruel_cost_image_id", {"id": fields.Integer()})

    def car_body(self):
        return self.namespace.model(
            "car_road_body_query",
            {
                "id": fields.Integer(),
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def cost_body(self):
        return self.namespace.model(
            "ruel_list_query",
            {
                "id": fields.Integer(),
                "mileage": fields.Float(),
                "oil_quantity": fields.Float(),
                "price": fields.Float(),
                "total_price": fields.Float(),
                "engineer": fields.String(),
                "remarks": fields.String(),
                "create_time": fields.DateTime(),
                "cars": fields.Nested(self.car_body()),
                "images": fields.List(fields.Nested(self.RuelImageCreateSchemas())),
            },
        )

    def cost_data(self):
        return self.namespace.model(
            "ruel_data",
            {"total": fields.Integer(), "data": fields.List(fields.Nested(self.cost_body()))},
        )

    def cost_list_query(self):
        return {
            "page": "页数",
            "per_page": "页总量",
            "mileage": "里程",
            "oil_quantity": "加油量",
            "price": "单价",
            "total_price": "总价",
            "engineer": "工程师",
            "remarks": "备注",
            "create_time": "加油时间",
            "car_num": "车号",
            "start_time": "起始时间",
            "end_time": "结束时间",
        }

    def cost_create_query(self):
        return self.namespace.model(
            "ruel_create_query",
            {
                "mileage": fields.Integer(),
                "oil_quantity": fields.Integer(),
                "price": fields.Integer(),
                "total_price": fields.Integer(),
                "engineer": fields.String(),
                "remarks": fields.String(),
                "create_time": fields.DateTime(),
                "car": fields.Integer(),
            },
        )

    def cost_id(self):
        return self.namespace.model("ruel_id", {"id": fields.Integer()})


class RoadCostSchemas(object):
    def __init__(self, namespace):
        self.namespace = namespace

    def RoadImageCreateSchemas(self):
        return self.namespace.model(
            "road_cost_images",
            {"id": fields.Integer(), "road_toll": fields.Integer(), "file": fields.String},
        )

    def RoadImageIdSchemas(self):
        return self.namespace.model("road_cost_image_id", {"id": fields.Integer()})

    def car_body(self):
        return self.namespace.model(
            "car_road_body_query",
            {
                "id": fields.Integer(),
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def cost_body(self):
        return self.namespace.model(
            "road_list_query",
            {
                "id": fields.Integer(),
                "enterance": fields.String(),
                "export": fields.String(),
                "price": fields.Float(),
                "engineer": fields.String(),
                "remarks": fields.String(),
                "create_time": fields.DateTime(),
                "deleted": fields.Boolean(),
                "cars": fields.Nested(self.car_body()),
                "images": fields.List(fields.Nested(self.RoadImageCreateSchemas())),
            },
        )

    def cost_data(self):
        return self.namespace.model(
            "road_data",
            {"total": fields.Integer(), "data": fields.List(fields.Nested(self.cost_body()))},
        )

    def cost_list_query(self):
        return {
            "page": "页数",
            "per_page": "页总量",
            "road_name": "停车场名称",
            "enterance": "入口",
            "export": "出口",
            "price": "价格",
            "price_total": "总价",
            "engineer": "工程师",
            "remarks": "备注",
            "create_time": "创建时间",
            "enter_time": "进入时间",
            "deleted": "删除",
            "start_time": "起始时间",
            "end_time": "结束时间",
            "car_num": "车号",
        }

    def cost_create_query(self):
        return self.namespace.model(
            "road_create_query",
            {
                "enterance": fields.String(),
                "export": fields.String(),
                "price": fields.Float(),
                "engineer": fields.String(),
                "remarks": fields.String(),
                "create_time": fields.DateTime(),
                "deleted": fields.Boolean(),
                "car": fields.Integer(),
            },
        )

    def cost_id(self):
        return self.namespace.model("road_id", {"id": fields.Integer()})


class ParkingCostSchemas(object):
    def __init__(self, namespace):
        self.namespace = namespace

    def ParkingImageCreateSchemas(self):
        return self.namespace.model(
            "parking_cost_images",
            {"id": fields.Integer(), "parking": fields.Integer(), "file": fields.String()},
        )

    def ParkingImageIdSchemas(self):
        return self.namespace.model("parking_cost_image_id", {"id": fields.Integer()})

    def car_body(self):
        return self.namespace.model(
            "car_road_body_query",
            {
                "id": fields.Integer(),
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def cost_body(self):
        return self.namespace.model(
            "parking_list_query",
            {
                "id": fields.Integer(),
                "parking": fields.String(),
                "price": fields.Float(),
                "enter_time": fields.DateTime(),
                "out_time": fields.DateTime(),
                "engineer": fields.String(),
                "remarks": fields.String(),
                "create_time": fields.DateTime(),
                "deleted": fields.Boolean(),
                "cars": fields.Nested(self.car_body()),
                "images": fields.List(fields.Nested(self.ParkingImageCreateSchemas())),
            },
        )

    def cost_data(self):
        return self.namespace.model(
            "parking_data",
            {"total": fields.Integer(), "data": fields.List(fields.Nested(self.cost_body()))},
        )

    def cost_list_query(self):
        return {
            "page": "页数",
            "per_page": "页总量",
            "parking": "停车场名称",
            "price": "价格",
            "enter_time": "进入时间",
            "out_time": "出时间",
            "engineer": "工程师",
            "remarks": "备注",
            "create_time": "创建时间",
            "deleted": "是否删除",
            "car_num": "车号",
            "start_time": "起始时间",
            "end_time": "结束时间",
        }

    def cost_create_query(self):
        return self.namespace.model(
            "parking_create_query",
            {
                "parking": fields.String(),
                "price": fields.Float(),
                "enter_time": fields.DateTime(),
                "out_time": fields.DateTime(),
                "engineer": fields.String(),
                "remarks": fields.String(),
                "create_time": fields.DateTime(),
                "deleted": fields.Boolean(),
            },
        )

    def cost_id(self):
        return self.namespace.model("parking_id", {"id": fields.Integer()})
